//-----------------------------------------------------------------------
// <copyright company="Olson Software Limited">
//      (c) Copyright Olson Software Limited.
//      This source is subject to the Microsoft Public License (Ms-PL).
//      Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details.
//      All other rights reserved.
// </copyright>
//-----------------------------------------------------------------------

using System;
using System.Security.Principal;

namespace Insight.Library.Navigation
{
    [AttributeUsage(AttributeTargets.Class)]
    public class RequiresAuthenticationAttribute : AuthorizationAttribute
    {
        public override bool Authorize(IPrincipal principal)
        {
            if (principal == null)
            {
                throw new ArgumentNullException("principal");
            }
            if (principal.Identity == null)
            {
                return false;
            }

            return principal.Identity.IsAuthenticated;
        }
    }
}